#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

typedef vector< int>   vint; 
typedef vector< vector<int> > vvint;
typedef vector< vector< vector<int> > > vvvint;

int cota ;

int wayClosestTarget(int i, int j, int target, vvint& matriz, vvvint& mem) {
	if (target > cota) return cota;
	
	if (mem[i][j][target] >= 0) return mem[i][j][target];

    int& actual = matriz[i][j];

	int distancia1 = abs(target - actual);
	int distancia2 = abs(target + actual);
    int res;
	if ( i==0 && j==0 ) {
		return min (distancia1, distancia2);
	} else {
		if ( i==0 || j==0 ) {
			if (i == 0) { // j > 0
                res = min(wayClosestTarget(i, j-1, distancia1, matriz, mem), wayClosestTarget(i, j-1, distancia2, matriz, mem));
                mem[i][j][target] = res; 
				return res;
			} else { // i> 0
                res = min(wayClosestTarget(i-1, j, distancia1, matriz, mem), wayClosestTarget(i-1, j, distancia2, matriz, mem));
                mem[i][j][target] = res;
				return res;
			}	
		} else {  // i > 0 y j > 0
            res = min(
                    min(wayClosestTarget(i, j-1, distancia1, matriz, mem), wayClosestTarget(i, j-1, distancia2, matriz,mem)),
                    min(wayClosestTarget(i-1, j, distancia1, matriz, mem), wayClosestTarget(i-1, j, distancia2, matriz, mem))
                    );
            mem[i][j][target] = res;
            return res; 
		}
	}
}

int resolver( vvint& matriz, int n ) {
    vvvint mem(n, vvint(n, vint(cota+1,-1)));
    int res = wayClosestTarget(n-1,n-1,0, matriz, mem);
    return res;
}

int main() {
	
    int n;
    cin >> n;
    
    while ( n != 0 ) {
        vvint matriz(n, vint(n, 0));
        int cantElem = 0;
        int maxpiramide = 0;
		int valor, valorabs;
		int x, y;    
        for( int i = 0; i < (2*n - 1); ++i ){
            
            i < n ? ++cantElem : --cantElem;
    
            for( int j = 0; j < cantElem ; ++j ){
                cin >> valor;
                valorabs = abs(valor);
                if (i < n) {
                    y = i - j;
                    x = i - y;
                } else {
                    x = i + j - (n - 1);
                    y = i - x;
                }
                if (valorabs > maxpiramide) maxpiramide = valorabs;
                matriz[x][y] = valor;
            }
        }
		cota = n * maxpiramide;
        cout << resolver(matriz, n) << endl;
		cin >> n;
    }
    
    return 0;
}


